#include <math.h>
#include "parm.h"
#include "func.h"


double omega(double a, double r) {
	return 1.0 / (fabs(a) + pow(r, 1.5));
}

double phi(double x, double y) {
	return atan2(y, x);
}

double phiem(double x, double y, double xr, double xth) {
	return phi(x, y) - xr - xth;
}

int normalization_time(double time, double period, int time_resolution) {
	double t_in_p = time / period - floor(time/period);
	return floor(t_in_p * time_resolution);
}

//�������鷵��
void fractional_rms(double* begin, int count, double* sum_square, double* N_ph) {

	double sum_x = 0;
	for (int i = 0; i < count; ++i)
	{
		sum_x += *(begin + i);
	}
	double average = sum_x / count;

	double sum_x_square = 0;
	for (int i = 0; i < count; i++)
	{
		sum_x_square += pow(*(begin + i) - average, 2);
	}

	*sum_square = sum_x_square;
	*N_ph = sum_x;

}

